package com.xiaotu.spider.maoyan.pipeline;

import org.springframework.stereotype.Component;

import com.xiaotu.common.model.MaoYanStarDetailModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @类名 MaoYanStarDetailPipeline
 * @日期 2018年6月25日
 * @作者 王艳龙
 * @功能 猫眼艺人详细信息数据pipeline
 */
@Component("MaoYanStarDetailPipeline")
public class MaoYanStarDetailPipeline extends APipeline
{
    @Override
    protected void doProcess(ResultItems resultItems, Task task)
    {
        MaoYanStarDetailModel startDetail = resultItems.get(MaoYanStarDetailModel.class.getName());
        if (startDetail == null)
            return;
        
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.MAOYAN_STAR_DETAIL_YYYYMMDD);
    	cacheHandler.hSet(key, startDetail.getName()+"_"+startDetail.getTimestamp()+"", startDetail);
        cacheHandler.setCacheTimeout(key);
    }

}